<?php
/**
* @desc 火热特卖表单处理
* @author kevin.wang
* @date 2015-01-01 12:00:00
**/
class HotSaleForm extends BaseForm
{
	public $hotsale_keyword;
	public $category;
	public $goods_id;
	public $sort;
	public $is_show;
	public $hot_url;
	//表单规则
	public function rules()
	{
		return array(
			array('hotsale_keyword, category, goods_id, sort, is_show, hot_url', 'required', 'message'=>'必填字段不能为空'),
			array('hotsale_keyword', 'unique' , 'on'=>'add', 'className'=>'HotSale', 'message'=>'火热特卖关键字已存在'),
			array('sort, goods_id', 'numerical', 'message'=>'排序必须为数字'),
			array('is_show', 'boolean', 'message'=>'是否显示为布尔值')
		);
	}
	//写入数据
	public function saveData(){
		$model = new HotSale;
		$userInfo = json_decode(Yii::app()->session['userinfo'], true);
		$data = $this->attributes;
		$data['author'] = $userInfo['username'];
		return $model->insertHotSale($data);
	}
	//修改数据
	public function editData($id){
		$model = new HotSale;
		return $model->editHotSale($id, $this->attributes);
	}
}
